package com.faxsun.payment.service.gateway;

import javassist.expr.NewArray;

import com.faxsun.model.response.Response;
import com.faxsun.model.response.result.QueryPaymentResult;

public class PaySSSHostedGatewayMockupServiceImpl implements PaySSSHostedGatewayService {

	@Override
	public boolean isEnabledSignVerify() {
		return false;
	}

	@Override
	public String callPaymentResult(final String orderId, final int orderAmount, final String itemTitle,
			final String itemDesc) {
		StringBuffer faxsunResult = new StringBuffer();
		faxsunResult.append("<!DOCTYPE HTML>");
		faxsunResult
				.append("<!--[if lt IE 7]> <html class=\"no-js lt-ie9 lt-ie8 lt-ie7\" lang=\"en\"> <![endif]-->");
		faxsunResult.append("<!--[if IE 7]> <html class=\"no-js lt-ie9 lt-ie8\" lang=\"en\"> <![endif]-->");
		faxsunResult.append("<!--[if IE 8]> <html class=\"no-js lt-ie9\" lang=\"en\"> <![endif]-->");
		faxsunResult.append("<!--[if gt IE 8]><!--> <html class=\"no-js\" lang=\"en\"> <!--<![endif]-->");
		faxsunResult.append("<body>");
		faxsunResult.append("<h1>Mock Hosted Checkout</h1>");
		faxsunResult
				.append("<p>This is an zexample to show the flow of a Hosted Third Party Checkout Integration (e.g. PaySSS Checkout)</p>");
		faxsunResult
				.append("<p>This customer will be prompted to either enter their credentials or fill out their payment information. Once complete, "
						+ "they will be redirected back to either a confirmation page or a review page to complete checkout.</p>");
		faxsunResult.append("<form action=\"/shop/paysss/hosted/return"
				+ "\" method=\"GET\" id=\"PaySSSRedirectForm\" name=\"PaySSSRedirectForm\">");
		// faxsunResult.append("<form action=\"/shop/paysss/hosted/notify"
		// +
		// "\" method=\"POST\" id=\"PaySSSRedirectForm\" name=\"PaySSSRedirectForm\">");
		// channel_id
		faxsunResult.append("channel_id<input type=\"text\" name=\"" + "channel_id" + "\" value=\""
				+ "2015010700825093" + "\"/><br />");
		// order_amountt
		faxsunResult.append("order_amount<input type=\"text\" name=\"" + PaymentGatewayConstants.ORDER_AMOUNT
				+ "\" value=\"" + orderAmount + "\"/><br />");
		// order_currency
		faxsunResult.append("order_currency<input type=\"text\" name=\"" + "order_currency" + "\" value=\""
				+ "156" + "\"/><br />"); // order_id
		faxsunResult.append("order_id<input type=\"text\" name=\"" + PaymentGatewayConstants.ORDER_ID
				+ "\" value=\"" + orderId + "\"/><br />");
		// pay_channel
		faxsunResult.append("pay_channel<input type=\"text\" name=\"" + "pay_channel" + "\" value=\""
				+ "alipay" + "\"/><br />");
		// payment_endtime
		faxsunResult.append("payment_endtime<input type=\"text\" name=\"" + "payment_endtime" + "\" value=\""
				+ "20150107170448" + "\"/><br />");
		// pid
		faxsunResult.append("pid<input type=\"text\" name=\"" + "pid" + "\" value=\""
				+ "fe4ef5f936ca497395729f2368776072" + "\"/><br />");
		// seller_name
		faxsunResult.append("seller_name<input type=\"text\" name=\"" + "seller_name" + "\" value=\""
				+ "ADSON" + "\"/><br />");
		// seller_piggy_back
		faxsunResult.append("seller_piggyback<input type=\"text\" name=\"" + "seller_piggyback"
				+ "\" value=\"" + "merchant_piggy_back" + "\"/><br />");
		// sign
		faxsunResult.append("sign<input type=\"text\" name=\"" + "sign" + "\" value=\""
				+ "B0691B0980B7A0FBCA4D2A8A8DE61190" + "\"/><br />");
		// complete_checkout_on_callback
		// faxsunResult.append("complete_checkout_on_callback<input type=\"text\" name=\""
		// + PaymentGatewayConstants.COMPLETE_CHECKOUT_ON_CALLBACK +
		// "\" value=\"true\"/><br />");
		faxsunResult.append("<input type=\"submit\" value=\"Please Click Here To Complete Checkout\"/>");
		faxsunResult.append("</form>");
		faxsunResult.append("</body>");
		faxsunResult.append("</html>");

		return faxsunResult.toString();
	}

	@Override
	public Response<QueryPaymentResult> queryPaymentResultByOrderId(long orderId) {
		Response<QueryPaymentResult> paymentResult = new Response<QueryPaymentResult>();
		paymentResult.setResult(new QueryPaymentResult());
		// Always return true for mock up payment result.
		paymentResult.getResult().setStatus(PaymentGatewayConstants.PAYMENT_RESULT_SUCCESS);

		return paymentResult;
	}

}
